<template>
  <div class="work-container">
    <div class="head-title">报工单历史</div>
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="load"
    >
      <van-cell
        v-for="(item, index) in list"
        :key="index"
        :title="item.rfwordType === '0' ? '计件报工' : '零工报工'"
        :value="item.rfworkDate"
        @click="gotoDetail(item)"
      >
        <template #label>
          报工人: {{item.rfworkNick}} <br>
          <van-tag
            v-if="item.leaderPass==='0'"
            type="primary"
          >审核通过</van-tag>
          <van-tag
            v-if="item.leaderPass==='1'"
            type="warning"
          >审核未通过</van-tag>
          <van-tag
            v-if="item.recheckPass==='0'"
            type="primary"
          >复核通过</van-tag>
          <van-tag
            v-if="item.recheckPass==='1'"
            type="warning"
          >复核未通过</van-tag>
        </template>
      </van-cell>
    </van-list>
  </div>
</template>

<script>
import { Notify } from "vant";


import { listRfwork, getRfwork } from "@/api/sl/rfwork";

export default {
  name: "h5Job",
  components: {
    [Notify.Component.name]: Notify.Component,
  },
  data() {
    return {
      activeName: "first",
      // 查询参数
      queryParams01: {
        pageNum: 1,
        pageSize: 999,
      },
      list: [],
      total: 0,
      finished: false,
      loading: false,
    };
  },
  computed: {},
  created() {
    //获取当前报工人信息
    // this.getRworkUserBase(this.$store.state.user.name);
    this.load();
  },
  methods: {
    reset() {
      this.list = [];
      this.queryParams01.pageNum = 1;
      this.total = 0;
      this.finished = false;
      this.load();
    },
    load() {
      console.log(this.activeName);
      this.loading = true;
      this.listRfwork();
    },
    /** 查询报工单列表 */
    // http://localhost:1024/dev-api/sl/rfwork/list?pageNum=1&pageSize=10
    listRfwork() {
      this.loading = true;
      if (!this.finished) {
        listRfwork(this.queryParams01).then((response) => {
          if (response.code === 200) {
            this.list = [...this.list, ...response.rows];
            this.total = response.total;
            this.loading = false;
            if (this.queryParams01.pageNum * this.queryParams01.pageSize < this.total) {
              this.finished = false;
              this.queryParams01.pageNum += 1;
            } else {
              this.finished = true;
            }
          } else {
            Notify({ type: "danger", message: "出错了" });
          }
        });
      }
    },
    gotoDetail(item) {
      if (item.rfwordType === '0') {
        // 计件
        // http://localhost:1024/dev-api/sl/rwork/hlist?pageNum=1&pageSize=10&rfworkId=8
        this.$router.push({ path: '/h5/rfwork-jijian?rfworkId=' + item.rfworkId })
      } else {
        // 零工
        // http://localhost:1024/dev-api/sl/oddjob/hlist?pageNum=1&pageSize=10&rfworkId=9
        this.$router.push({ path: '/h5/rfwork-linggong?rfworkId=' + item.rfworkId })
      }
    }
  },
};
</script>

<style lang="scss" scoped>
.work-container {
  min-height: 100vh;
  padding: 15px;
  background: linear-gradient(135deg, #c9deff 4%, white 80%);
  &::v-deep {
    .van-tag {
      & + .van-tag {
        margin-left: 5px;
      }
    }
  }
}
.head-title {
  font-size: 18px;
  font-weight: bold;
  color: #333;
  margin-bottom: 10px;
}
@media (max-width: 550px) {
}
</style>
